#include <iostream>
#include <cerrno>
#include <unistd.h>
#include <pthread.h>

void *threadRun1(void *args)
{
    while (true)
    {
        std::cout << "thread1, errno: " << errno << std::endl;
        sleep(1);
    }
}

void *threadRun2(void *args)
{
    while (true)
    {
        errno++;
        std::cout << "thread2, errno: " << errno << std::endl;
        sleep(1);
    }
}

int main()
{
    pthread_t tid1, tid2;
    pthread_create(&tid1, nullptr, threadRun1, nullptr);
    pthread_create(&tid1, nullptr, threadRun2, nullptr);

    pthread_join(tid1, nullptr);
    pthread_join(tid2, nullptr);
    return 0;
}